import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_cookbook/test_widget/todoList.dart';

/// flutter test test/test_widget/tapWidget.dart
void main() {
  testWidgets('Add and remove a todo', (WidgetTester tester) async {
    // 输入文本
    await tester.pumpWidget(TodoList());
    await tester.enterText(find.byType(TextField), 'hi');
    // 点击按钮
    await tester.tap(find.byType(FloatingActionButton));
    await tester.pump();
    expect(find.text('hi'), findsOneWidget);
    //滑动
    await tester.drag(find.byType(Dismissible), Offset(500.0, 0.0));
    await tester.pumpAndSettle();
    expect(find.text('hi'), findsNothing);
  });
}
